import { HttpClient } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Result } from 'src/app/common/bean/result-bean';
import { ArticleVo } from '../../vo/article-vo';

@Component({
  selector: 'app-article-page',
  templateUrl: './article-page.component.html',
  styleUrls: ['./article-page.component.scss'],
})
export class ArticlePageComponent implements OnInit {
  articleId: string;

  articleVo: ArticleVo;

  loading: boolean = true;

  constructor(private route: ActivatedRoute, private http: HttpClient) {}

  ngOnInit(): void {
    this.articleId = this.route.snapshot.paramMap.get('articleId');
    this.getArticle();
  }

  getArticle() {
    this.http
      .get<Result<ArticleVo>>(
        '/article/getArticle?articleId=' + this.articleId
      )
      .subscribe((result) => {
        this.articleVo = result.data;
        this.loading=false;
      });
  }
}
